﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using NewComer06.MVP;

namespace NewComer06.VSWebpart_ShowAll
{
    public partial class VSWebpart_ShowAllUserControl : UserControl, IComerView
    {
        ShowAllPresenter _present;

        protected void Page_Load(object sender, EventArgs e)
        {
            _present = new ShowAllPresenter(this);
            _present.DataBind(4);

        }

        public System.Collections.Generic.List<Comer> listComers
        {
            get;
            set;
        }

        protected void RenderByCtrl(string htmlStr)
        {
            Controls.Add(new LiteralControl(htmlStr));
        }

        protected void DocumentsRenderTableHeader()
        {
            Controls.Add(new LiteralControl("<table id=\"results\" class=\"tableBorder\">"));

            Controls.Add(new LiteralControl("<tr>"));
            Controls.Add(new LiteralControl("<td class=\"titleFirst\">" + "Show All New Comers"));

            Controls.Add(new LiteralControl("</td>"));
            Controls.Add(new LiteralControl("</tr>"));
           
            foreach (Comer th in listComers)
            {

                Controls.Add(new LiteralControl("<tr>"));
                Controls.Add(new LiteralControl("<td>"));

                Controls.Add(new LiteralControl("<table width=\"100%>\"")); 
                Controls.Add(new LiteralControl("<tr>"));
                Controls.Add(new LiteralControl("<td class=\"title\" >" + th.FirstName + " " + th.LastName ));
                Controls.Add(new LiteralControl("</td>"));
                
                Controls.Add(new LiteralControl("<td rowspan=\"8\" class=\"imageBorder\"><img alt=\"\" src=\""+ th.Picture.Substring(0, th.Picture.Length - 2) +"\" />"));
                Controls.Add(new LiteralControl("</td>"));
                Controls.Add(new LiteralControl("</tr>"));
                
                Controls.Add(new LiteralControl("<tr>"));
                Controls.Add(new LiteralControl("<td> Job Title: " + th.Jobtitle));
                Controls.Add(new LiteralControl("</td>"));
                Controls.Add(new LiteralControl("</tr>"));
                
                Controls.Add(new LiteralControl("<tr>"));
                Controls.Add(new LiteralControl("<td>  Project: " + th.Project));          
                Controls.Add(new LiteralControl("</td>"));
                Controls.Add(new LiteralControl("</tr>"));
                
                Controls.Add(new LiteralControl("<tr>"));
                Controls.Add(new LiteralControl("<td> Report to: " + th.Reportto));
                Controls.Add(new LiteralControl("</td>"));
                Controls.Add(new LiteralControl("</tr>"));
                
                Controls.Add(new LiteralControl("<tr>"));
                Controls.Add(new LiteralControl("<td> Skill: " + th.Skill));          
                Controls.Add(new LiteralControl("</td>"));
                Controls.Add(new LiteralControl("</tr>"));
                
                Controls.Add(new LiteralControl("<tr>"));
                Controls.Add(new LiteralControl("<td> Source: " + th.Source));            
                Controls.Add(new LiteralControl("</td>"));
                Controls.Add(new LiteralControl("</tr>"));
                
                Controls.Add(new LiteralControl("<tr>"));
                Controls.Add(new LiteralControl("<td> Start Date: " + th.StartDate));
                Controls.Add(new LiteralControl("</td>"));
                Controls.Add(new LiteralControl("</tr>"));
                
                Controls.Add(new LiteralControl("<tr>"));
                Controls.Add(new LiteralControl("<td>")); 
                Controls.Add(new LiteralControl("<a href=\"http://w3schools.com/html/tryit.asp?filename=tryhtml_pulpitimage\">Edit </a>"));
                Controls.Add(new LiteralControl("</td>"));
                Controls.Add(new LiteralControl("</tr>"));

                Controls.Add(new LiteralControl("<tr>"));
                Controls.Add(new LiteralControl("<td colspan=\"2\">"));
                Controls.Add(new LiteralControl("<hr size=\"1\" align=left class=\"styleHr\" />"));
                Controls.Add(new LiteralControl("</td>"));
                Controls.Add(new LiteralControl("</tr>"));

                Controls.Add(new LiteralControl("</table>"));

                Controls.Add(new LiteralControl("</td>"));
                Controls.Add(new LiteralControl("</tr>"));


            }
            Controls.Add(new LiteralControl("<tr>"));
            Controls.Add(new LiteralControl("<td>"));
            Controls.Add(new LiteralControl("<div id=\"pageNavPosition\"></div>"));
            Controls.Add(new LiteralControl("<div>"));
            Controls.Add(new LiteralControl("<a href=\"http://w3schools.com/html/tryit.asp?filename=tryhtml_pulpitimage\">Add New</a>"));
            Controls.Add(new LiteralControl("</div>"));
            Controls.Add(new LiteralControl("</td>"));
            Controls.Add(new LiteralControl("</tr>"));

            Controls.Add(new LiteralControl("</table>"));
            


            Controls.Add(new LiteralControl("<script type=\"text/javascript\">"));
            Controls.Add(new LiteralControl("var pager = new Pager('results', 3);"));
            Controls.Add(new LiteralControl("pager.init();"));
            Controls.Add(new LiteralControl("pager.showPageNav('pager', 'pageNavPosition');"));
            Controls.Add(new LiteralControl("pager.showPage(1);"));
            Controls.Add(new LiteralControl("</script>"));
        }




        public void TableBinding()
        {
            DocumentsRenderTableHeader();
        }
    }
}
